package com.ruoyi.warning.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.warning.domain.entity.WirelessSensors;
import com.ruoyi.warning.domain.entity.WirelessSensorsManual;
import com.ruoyi.warning.mapper.WirelessSensorsManualMapper;
import com.ruoyi.warning.service.IWirelessSensorsManualService;
import com.ruoyi.warning.service.IWirelessSensorsService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 手动添加的 服务实现类
 * </p>
 *
 * @author chenhc
 * @since 2025-07-08
 */
@Service
public class WirelessSensorsManualServiceImpl extends ServiceImpl<WirelessSensorsManualMapper, WirelessSensorsManual> implements IWirelessSensorsManualService {
@Resource
private IWirelessSensorsService wirelessSensorsService;
    @Value("${spring.profiles.active:}")
    private String activeProfile;
    @Override
    public Object refresh() {
        //找到所有的手动添加的设备
        List<WirelessSensorsManual> list = this.list();
        for (WirelessSensorsManual manual : list) {
            if("ikd".equals(activeProfile)){
                wirelessSensorsService.addACAPRuijie(manual.getDeviceId());
            }else {
                wirelessSensorsService.addACAP(manual.getDeviceId());
            }

        }
        //找到自动添加的设备，补全信息
        List<WirelessSensors> listS = wirelessSensorsService.list();
        for (WirelessSensors sensors : listS) {
            if(sensors.getSensorClass().equals("clients")){
//                wirelessSensorsService.completionACAP(sensors.getDeviceId());
            }
        }
        return null;
    }

    @Override
    public Object refreshMap() {
        //找到所有的手动添加的设备
        List<WirelessSensorsManual> list = this.list();
        for (WirelessSensorsManual manual : list) {
            wirelessSensorsService.addACAPMap(manual.getDeviceId());
        }
        return null;
    }
}
